package com.chief.dubboFeign.controller;

import com.chief.dubboFeign.DubboFeignGateWayTestService;
import com.chief.dubboFeign.DubboFeignTestService;
import com.chief.dubboFeign.DubboTestService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class IndexController {

    @Autowired
    private DubboFeignTestService dubboFeignTestService;

    @DubboReference
    private DubboFeignGateWayTestService dubboFeignGateWayTestService;

    @DubboReference
    private DubboTestService dubboTestService;

    @GetMapping("/index")
    public Map<String, String> index() {
        Map<String, String> res = new HashMap<>();
        res.put("feign", this.dubboFeignTestService.test("name"));
        res.put("gateway", this.dubboFeignGateWayTestService.test());
        res.put("dubbo", this.dubboTestService.getName());
        return res;
    }

}
